#include<bits/stdc++.h>
using namespace std;

//rp++
struct Car
{
    int d,v,a,id;
    double dct=0,stop=0;
    void read(int i,int V)
    {
        id=i;
        cin>>d>>v>>a;
        if(a>0)
        {
            if(v>V)
            {
                dct=d;
            }
            else
            {
                dct=d+(1.0*V*V-1.0*v*v)/(2*a);
            }
        }
        if(a==0)
        {
            if(v>V)
            {
                dct=d;
            }
        }
        if(a<0)
        {
            if(v>V)
            {
                dct=d;
            }
            stop=d+double(V*V-v*v)/(2*a);
        }
        //cout<<d<<' '<<dct<<' '<<stop<<endl;
    }
}car[100005];



bool cmp(Car x,Car y)
{
    return x.dct<y.dct;
}

int p[100005];

int main()
{
    freopen("detect.in","r",stdin);
    freopen("detect.out","w",stdout);
    int T;
    cin>>T;
    for(int t=1;t<=T;t++)
    {
        memset(car,0,sizeof(car));
        memset(p,0,sizeof(p));
        int cnt=0,cur=0;
        bool f1=0,f0=0,fn=0;
        int n,m,L,V;
        cin>>n>>m>>L>>V;


        for(int i=1;i<=n;i++)
        {
            car[i].read(i,V);
            if(car[i].a>0)f1=1;

            if(car[i].a==0)f0=1;
            
            if(car[i].a<0)fn=1;
        }

        sort(car+1,car+n+1,cmp);
        //cout<<f1<<' '<<f0<<' '<<fn<<endl;
        for(int i=1;i<=m;i++)
        {
            cin>>p[i];
        }
        if(!fn)
        {
            //cout<<n<<' '<<m<<' '<<L<<' '<<V<<endl;
            for(int i=1;i<=n;i++)
            {
                if(p[m]<=car[i].dct||L<car[i].dct)
                {
                    break;
                }
                if(car[i].dct&&car[i].dct<L)
                {
                    cnt++;
                    //cout<<cnt<<' '<<car[i].id<<' '<<car[i].dct<<endl;
                }
            }
            if(cnt)cur=m-1;
            else cur=m;
            cout<<cnt<<' '<<cur<<endl;
            continue;
        }
            int l1=1,l2=1;
            while(l1<=n&&l2<=m)
            {
                l1++;
                if(!car[l1].stop)
                {
                    if(p[l2]>=car[l1].dct)
                    {
                        cnt++;
                    }    
                    else{
                        l2++;
                    }
                }
            }
            

    }
    return 0;
}